﻿<Window x:Class="DemoApp_MRU.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="650" Width="525"
        
        xmlns:conv="clr-namespace:DemoApp_MRU.Converters"
        xmlns:views="clr-namespace:MRULib;assembly=MRULib"
        xmlns:behav="clr-namespace:MRULib.Behaviours;assembly=MRULib"
        >
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        
        <Menu Grid.Row="0">
            <MenuItem Header="File">
                <MenuItem ItemsSource="{Binding MruList.ListOfMRUEntries}"
                          Header="Recent Files ..."
                          Visibility="{Binding Path=MruList.ListOfMRUEntries.Count, Mode=OneWay, UpdateSourceTrigger=PropertyChanged, Converter={conv:ZeroToVisibilityConverter}}"
                    >
                    <MenuItem.Resources>
                        <behav:BindingProxy x:Key="DataContextProxy" Data="{Binding MruList}" />
                    </MenuItem.Resources>
                    <MenuItem.ItemContainerStyle>
                        <Style TargetType="MenuItem">
                            <Setter Property="Header" Value="{Binding DisplayPathFileName, Mode=OneWay}" />
                            <Setter Property="ToolTip">
                                <Setter.Value>
                                    <StackPanel>
                                        <TextBlock  Text="{Binding PathFileName}" />
                                        <TextBlock  Text="{Binding Data.LoadFileCommandHeaderDescription, Source={StaticResource DataContextProxy}}" />
                                    </StackPanel>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Command" Value="{Binding Data.LoadFileCommand, Source={StaticResource DataContextProxy}}" />
                            <Setter Property="CommandParameter" Value="{Binding Mode=OneWay}" />
                            <Setter Property="ToolTipService.ShowOnDisabled" Value="True" />
                        </Style>
                    </MenuItem.ItemContainerStyle>
                </MenuItem>
                <MenuItem Header="Open..." />
                <MenuItem Header="Exit" />
            </MenuItem>
        </Menu>
        
        <TabControl Grid.Row="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
            <TabItem Header="MRU Demo" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                <views:RecentItems DataContext="{Binding MruList}"
                                   Margin="66,3"
                                   VerticalAlignment="Stretch"
                                   HorizontalAlignment="Stretch" />
            </TabItem>

            <TabItem Header="XML Demo" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    
                    <StackPanel Orientation="Horizontal">
                        <Button Content="GetXML" Margin="3" Command="{Binding GetXMLCommand}" />
                        <Button Content="SetXML" Margin="3" Command="{Binding SetXMLCommand}"/>
                    </StackPanel>
                    
                    <TextBox Grid.Row="1" Text="{Binding XMLDemoText,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                </Grid>
            </TabItem>
        </TabControl>
    </Grid>
</Window>
